package com.digiwin.escloud.test.core.listener;

import org.testng.IRetryAnalyzer;
import org.testng.ITestResult;

/**
 * @Author yanggld
 * @Date 2020/5/6-15:48
 */
public class FailedRetry implements IRetryAnalyzer {
	private int retryCount = 1;
	private static final int maxRetryCount = 2;

	@Override
	public boolean retry(ITestResult iTestResult) {
		//抛出异常则重跑失败案例
		if (iTestResult.getThrowable() instanceof Exception && retryCount % maxRetryCount != 0) {
			retryCount++;
			return true;
		} else {
			retryCount = 1;
			return false;
		}
	}
}
